"""
文件读取练习：单词计数
"""

with open("d:/word.txt", "r", encoding="UTF-8") as f:
    content = f.read()
    count = content.count("itheima")
    print(f"itheima在文件中出现的次数：{count}")

with open("d:/word.txt", "r", encoding="UTF-8") as f:
    content = ""
    for line in f:
        content += line.strip()
    print(f"文件内容：{content}")
    print(f"itheima在文件中出现的次数：{content.count('itheima')}")
